clear all
set more off
cd /Users/zimaoxiao/Dropbox/CC_Yield_Predict/replication_package/  // Navigate to replication folder on your own machine
global weather "timeInt0_3 timeInt3_6 timeInt6_9 timeInt9_12 timeInt12_15 timeInt15_18 timeInt18_21 timeInt21_24 timeInt24_27 timeInt27_30 timeInt30_33 timeInt33_36 timeInt36_39 prec prec2"

cap mkdir output
	
qui {	
use if inrange(year,1950,2000) using data/regression/reg_2020_prediction_3Cstep, clear
merge m:1 county_fips using data/yield/filter, keep(3) nogenerate

* column 1
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	

* column 2		
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend state_fips#c.trend2 [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	

* column 3	
eststo: xi: reghdfe lncornyield $weather [aweight=corn_areaHarv], absorb(county_fips state_fips#year) vce(cluster county_fips StateXYear)	
	
use if inrange(year,1950,2020) using data/regression/reg_2050_prediction_3Cstep, clear
merge m:1 county_fips using data/yield/filter, keep(3) nogenerate

* column 4
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	

* column 5		
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend state_fips#c.trend2 [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	

* column 6	
eststo: xi: reghdfe lncornyield $weather [aweight=corn_areaHarv], absorb(county_fips state_fips#year) vce(cluster county_fips StateXYear)	
		
noi esttab using output/TableS1.csv, keep($weather) ar2(%6.4f) scalar(N) compress star(* 0.1 ** 0.05 *** 0.01) b(%6.4f) se(%6.4f) nogaps noconstant replace								
}		

*** EOF
